<?php
//include_once("../connection.php");

class Rooms
{
	var $r_id;
	var $r_no;
	var $r_ty;
	var $r_pr;
		
//-------------new room------------------
	function new_room(){
		$ins_sql=mysql_query("INSERT INTO Room_tbl 
								VALUES(
									NULL,								
									'$this->r_no',
									'$this->r_ty',
									'$this->r_pr',
									1
								)							
							");	
		if($ins_sql)
			return "Add Room Sucess";
		else
			return "Error:".mysql_error();
	}
//--------------update room-------------------
function update_room(){
	$ins_sql=mysql_query("UPDATE Room_tbl 
								SET
									room_no='$this->r_no',										
									room_type='$this->r_ty',
									room_price='$this->r_pr'
								WHERE room_id='$this->r_id'															
							");	
		if($ins_sql)
			return "Update Room Sucess";
		else
			return "Error:".mysql_error();	
}

//-------------Delete room----------------
function del_stu(){
	$del_sql=mysql_query("UPDATE room_tbl SET active=0 WHERE room_id='$this->r_id'");
	if($del_sql)
		return "Delete Sucess";
	else
		return "Delete Fail".mysql_error;
	}
}




//---------------Reservation------------------------
class Reservation
{
	var $res_id;
	var $gue_id;
	var $rom_id;
	var $datein;
	var $dateout;
	var $note;
		
//-------------new room------------------
	function new_reserv(){
		$ins_sql=mysql_query("INSERT INTO Reservation_tbl 
								VALUES(
									NULL,								
									'$this->gue_id',
									'$this->rom_id',
									'$this->datein',
									'$this->dateout',
									'$this->note',
									1,
									1
								)							
							");	
		if($ins_sql)
			return "Add Reservation Sucess";
		else
			return "Error:".mysql_error();
	}
//--------------update room-------------------
function update_reserv(){
	$ins_sql=mysql_query("UPDATE reservation_tbl 
								SET
									guest_id='$this->gue_id',										
									room_id='$this->rom_id',
									date_in='$this->datein',
									date_out='$this->dateout',
									notes='$this->note'
								WHERE res_id='$this->res_id'															
							");	
		if($ins_sql)
			return "Update Reservation Sucess";
		else
			return "Error:".mysql_error();	
}

//-------------Delete room----------------
function del_res(){
	$del_sql=mysql_query("UPDATE reservation_tbl 
								SET 
									active=0 
								WHERE res_id='$this->res_id'");
	if($del_sql)
		return "Delete Sucess";
	else
		return "Delete Fail".mysql_error();
	}
}


class Users
{
	var $u_id;
	var $emp_id;
	var $uid;
	var $pwd;
		
//-------------new user------------------
	function new_user(){
		$ins_sql=mysql_query("INSERT INTO user_tbl 
								VALUES(
									NULL,								
									'$this->emp_id',
									'$this->uid',
									'$this->pwd',
									1
								)							
							");	
		if($ins_sql)
			return "Add User Sucess";
		else
			return "Error:".mysql_error();
	}
//--------------update room-------------------
function update_user(){
	$ins_sql=mysql_query("UPDATE user_tbl 
								SET
									username='$this->uid',										
									password='$this->pwd',
									emp_id='$this->emp_id'
								WHERE user_id='$this->u_id'															
							");	
		if($ins_sql)
			return "Update User Sucess";
		else
			return "Error:".mysql_error();	
}

//-------------Delete room----------------
function del_user($del_id){
	$del_sql=mysql_query("UPDATE user_tbl SET active=0 WHERE user_id=$del_id");
	if($del_sql)
		return "Delete Sucess";
	else
		return "Delete Fail".mysql_error;
	}
}


//---------------CheckIn------------------------
class Checkin
{
	var $che_id;
	var $gue_id;
	var $rom_id;
	var $datein;
	var $dateout;
	var $note;
	var $adult;
	var $kid;
	var $day;
	var $subtotal;
	var $discount;
	var $gtotal;
	var $roomprice;
		
//-------------new room------------------
	function new_checkin(){
		$ins_sql=mysql_query("INSERT INTO checkin_room_tbl 
								VALUES(
									NULL,								
									'$this->gue_id',
									'$this->rom_id',
									'$this->roomprice',
									'$this->datein',
									'$this->dateout',
									'$this->adult',
									'$this->kid',
									'$this->day',
									'$this->subtotal',
									'$this->discount',
									'$this->gtotal',
									'$this->note',
									1,
									1
								)							
							");	
		if($ins_sql)
			return "Add CheckIn Sucess";
		else
			return "Error:".mysql_error();
	}
//--------------update room-------------------
function update_checkin(){
	$ins_sql=mysql_query("UPDATE reservation_tbl 
								SET
									guest_id='$this->gue_id',										
									room_id='$this->rom_id',
									date_in='$this->datein',
									date_out='$this->dateout',
									notes='$this->note'
								WHERE res_id='$this->res_id'															
							");	
		if($ins_sql)
			return "Update CheckIn Sucess";
		else
			return "Error:".mysql_error();	
}

//-------------Delete room----------------
function del_checkin($del_id){
	$del_sql=mysql_query("UPDATE room_tbl SET active=0 WHERE room_id=$del_id");
	if($del_sql)
		return "Delete Sucess";
	else
		return "Delete Fail".mysql_error;
	}
}


?>